package model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import dao.GetCnn;

import entity.khachhang;

public class KhachhangModel {
	public List<khachhang> timkhachhang(String strSearch) throws SQLException{
		List<khachhang> listkh = new ArrayList<khachhang>();
		Connection cnn = GetCnn.getCnn();
		Statement stat = cnn.createStatement();		
		ResultSet rs = stat.executeQuery(strSearch);
		while(rs.next()){
			khachhang entity = new khachhang();
			entity.setMakh(rs.getString("MAKH"));
			entity.setTendangnhap(rs.getString("TENDANGNHAP"));
			entity.setMatkhau(rs.getString("MATKHAU"));
			entity.setHoten(rs.getString("HOTEN"));
			entity.setNgaysinh(rs.getString("NGAYSINH"));
			entity.setDiachi(rs.getString("DIACHI"));
			entity.setDienthoai(rs.getString("DIENTHOAI"));
			entity.setEmail(rs.getString("EMAIL"));
			entity.setNgaydk(rs.getString("NGAYDK"));
			listkh.add(entity);
		}
		return listkh;
	}

}
